﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using Enterprise.Infrastructure;
using Enterprise.Model.Article;
using Enterprise.Service.Article;
namespace Enterprise.UI.Web.Modules.Article
{
    /// <summary>
    /// Article 的摘要说明
    /// </summary>
    public class Article : IHttpHandler
    {
        /// <summary>
        ///  新闻通知模块内容,模块编号
        /// </summary>
        int Id = (int)Utility.sink("Id", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            ArticleService aService = new ArticleService();
            List<ArticleEntity> list = aService.ArticleQianshouList(aService.ArticleList(Id)).OrderByDescending(p => p.ACreateTime).Take(7).ToList();
            StringBuilder sb = new StringBuilder();
            foreach (ArticleEntity entity in list)
            {
                sb.Append("<div id=\"rightlinks\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>");
                sb.Append(" <td width=\"23\" align=\"left\" valign=\"middle\">  ●</td>");
                sb.Append("<td align=\"left\" valign=\"middle\" style=\"padding-right: 9px\"><a href=\"/Modules/Article/Details.aspx?Id=" + entity.ArticleId + "\" target=\"_blank\">" + entity.ATitle + "</a></td>");
                sb.Append(" <td width=\"80\" align=\"center\" valign=\"middle\" class=\"newsdate\">" + entity.ACreateTime.ToString("yyyy- MM- dd") + "</td>");
                sb.Append("</tr></table></div>");
            }
            sb.Append("<table align=\"right\"><tr><td align=\"right\" valign=\"bottom\"><a href=\"Modules/Article/Index.aspx?ModuleId=28\"><img src=\"styles/_img/more.gif\" width=\"51\" height=\"18\" /></a></td></tr></table>");
            context.Response.Write(sb.ToString());
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}